﻿<%@ Page Title="修改密码" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        * {
            font-family: 微软雅黑;
        }

        h1 {
            font-size: 14px;
        }
        /*密码强度*/ .pw-strength {
            clear: both;
            position: relative;
            top: 8px;
            width: 180px;
        }

        .pw-bar {
            background: url(../assets/img/pass/pwd-1.png) no-repeat;
            height: 14px;
            overflow: hidden;
            width: 179px;
        }

        .pw-bar-on {
            background: url(../assets/img/pass/pwd-2.png) no-repeat;
            width: 0px;
            height: 14px;
            position: absolute;
            top: 1px;
            left: 2px;
            transition: width .5s ease-in;
            -moz-transition: width .5s ease-in;
            -webkit-transition: width .5s ease-in;
            -o-transition: width .5s ease-in;
        }

        .pw-weak .pw-defule {
            width: 0px;
        }

        .pw-weak .pw-bar-on {
            width: 60px;
        }

        .pw-medium .pw-bar-on {
            width: 120px;
        }

        .pw-strong .pw-bar-on {
            width: 179px;
        }

        .pw-txt {
            padding-top: 2px;
            width: 180px;
            overflow: hidden;
        }

            .pw-txt span {
                color: #707070;
                float: left;
                font-size: 12px;
                text-align: center;
                width: 58px;
            }
      .msg{
          color:#ff0000;
      }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="container">
        <div class="row clearfix">
            <div class="col-md-12">
                 <div class="ibox float-e-margins">
                    <div class="ibox-content form-horizontal m-t">
                        <%--<form class="form-horizontal m-t" id="signupForm">--%>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">原密码：</label>
                                <div class="col-sm-8">
                                    <input id="password" name="password" class="form-control" type="password">
                                </div>
                            </div>
                             <div class="form-group">
                                <label class="col-sm-3 control-label">新密码：</label>
                                <div class="col-sm-8">
                                    <span class="tbl-txt">
                                    <input id="newpassword" name="newpassword" class="form-control" type="password">
                                        </span>
                                   <div id="level" class="pw-strength">
                                     <div class="pw-bar">
                                    </div>
                                    <div class="pw-bar-on">
                                    </div>
                                    <div class="pw-txt">
                                        <span>弱</span> <span>中</span> <span>强</span>
                                    </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">确认新密码：</label>
                                <div class="col-sm-8">
                                    <input id="confirm_password" name="confirm_password" class="form-control" type="password">
                                   <%-- <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>--%>
                                </div>
                            </div>
                         <div class="form-group">
                             <label class="col-sm-3 control-label"></label>
                             <div class="col-sm-8"> <span class="msg"></span></div>
                             </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary btn-save" >确认修改</button>
                                    <button class="btn btn-primary btn-cancel" >取    消</button>
                                </div>
                            </div>
                      <%--  </form>--%>

                    </div>
                </div>
             <%--   <table style="width: 420px;">
                    <tr>
                        <th>原密码
                        </th>
                        <td>
                            <span class="tbl-txt">
                                <input id="password" class="form-control input-text-width" size="30" maxlength="30" name="password" type="password" autocomplete="off" /></span>
                        </td>
                    </tr>
                    <tr>
                        <th>新密码
                        </th>
                        <td>
                            <span class="tbl-txt">
                                <input id="newpassword" class="form-control input-text-width" size="30" maxlength="30" name="newpassword" type="password" autocomplete="off" /></span>
                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td id="level" class="pw-strength">
                            <div class="pw-bar">
                            </div>
                            <div class="pw-bar-on">
                            </div>
                            <div class="pw-txt">
                                <span>弱</span> <span>中</span> <span>强</span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>确认新密码
                        </th>
                        <td>
                            <span class="tbl-txt">
                                <input id="confirm_password" class="form-control input-text-width" size="30" maxlength="30" name="confirm_password" type="password" autocomplete="off" /></span>
                        </td>
                    </tr>
                </table>--%>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script type="text/javascript">
        $(function () {
            var type = Y.getUrlParam('type');
            if (type == 1)
                $(".btn-cancel").hide();

            $('#newpassword').keyup(function () {
                var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
                var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
                var enoughRegex = new RegExp("(?=.{6,}).*", "g");

                if (false == enoughRegex.test($(this).val())) {
                    $('#level').removeClass('pw-weak');
                    $('#level').removeClass('pw-medium');
                    $('#level').removeClass('pw-strong');
                    $('#level').addClass(' pw-defule');
                    //密码小于六位的时候，密码强度图片都为灰色 
                }
                else if (strongRegex.test($(this).val())) {
                    $('#level').removeClass('pw-weak');
                    $('#level').removeClass('pw-medium');
                    $('#level').removeClass('pw-strong');
                    $('#level').addClass(' pw-strong');
                    //密码为八位及以上并且字母数字特殊字符三项都包括,强度最强 
                }
                else if (mediumRegex.test($(this).val())) {
                    $('#level').removeClass('pw-weak');
                    $('#level').removeClass('pw-medium');
                    $('#level').removeClass('pw-strong');
                    $('#level').addClass(' pw-medium');
                    //密码为七位及以上并且字母、数字、特殊字符三项中有两项，强度是中等 
                }
                else {
                    $('#level').removeClass('pw-weak');
                    $('#level').removeClass('pw-medium');
                    $('#level').removeClass('pw-strong');
                    $('#level').addClass('pw-weak');
                    //如果密码为6为及以下，就算字母、数字、特殊字符三项都包括，强度也是弱的 
                }
                return true;
            });

            $(".btn-save").on("click", function () {
                var pass = $("#password").val();
                var newpass = $("#newpassword").val();
                var confirmpass = $("#confirm_password").val();
                if (pass == "" || newpass == "" || confirmpass == "")
                {
                    $(".msg").text("输入框字段不能为空");
                    return false;
                }
                Y.API2('Users', 'SetPass', {
                    oldPass: md5(pass),
                    newPass: md5(newpass),
                    newPassRepeated: md5(confirmpass)
                }, function (data) {
                    if (data.Success == false) {
                        $(".msg").text(data.Message);
                        return false;
                    } else {
                        $(".msg").text("密码修改成功");
                        $(".msg").hide();
                        closeIframe();
                    }
                });
            })

            $(".btn-cancel").on("click",function () {
                closeIframe();
            })

            function closeIframe()
            {
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭  
            }
        })
    </script>
</asp:Content>

